<?php
namespace app\mall\controller;

class Index extends Base
{
    public function __construct (){
        parent::__construct();
        $this->params['appid'] = 111;
        $this->params['appsecret'] = 222;
        $this->clientInfo = $this->checkToken($this->params);
        if( $this->clientInfo['code'] != 200 ) {
            $this->error($this->clientInfo['msg']);
        }
    }

    //例子
    public function index(){
        $accessToken = $this->clientInfo['data']['access_token'];
        $uid = $this->clientInfo['data']['uid'];
        $appid = $this->clientInfo['data']['appid'];
        $base64 = base64_encode($appid.':'.$accessToken.':'.$uid);

        //一下列举三种方式请求
        //head方式请求
//        $headers = array(
//            'Content-Type: application/x-www-form-urlencoded',
//            'authentication: '.$uid.' '.$base64,
//        );
//        $read = curls('http://www.webplatform.com/v1/user',[],0,$headers);

        //post方式请求
//        $params = ['authentication' => $uid.' '.$base64];
//        $read = curls('http://www.webplatform.com/v1/user',$params,1);

        //get方式请求
        $params = [ 'authentication' => $uid.' '.$base64];
        $paramsString = http_build_query($params);
        $read = curls('http://www.webplatform.com/v1/user',$paramsString,0);
        dd($read);
    }
}
